package com.digital.smartgrow.service.title;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.CommendHonorMapper;
import com.digital.smartgrow.dto.title.CommendHonor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class CommendHonorServiceImpl implements CommendHonorService{



    @Autowired
    CommendHonorMapper commendHonorMapper;

    @Override
    @Transactional
    public List<CommendHonor> findList(CommendHonor commend) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard", commend.getIdcard());
        queryWrapper.eq("status", 0);
       return commendHonorMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void deleteCommend(CommendHonor commendHonor) {
        CommendHonor commendHonor1 = new CommendHonor();
        Date date = new Date();
        commendHonor1.setStatus(1).setId(commendHonor.getId()).setTime(date);
        commendHonorMapper.updateById(commendHonor1);
    }
}
